//---------------------------------------------------------------------------//
// Copyright (c) 2017-2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//---------------------------------------------------------------------------//

#ifndef MARSHALLING_REVERSE_MACRO_ARGS_HPP
#define MARSHALLING_REVERSE_MACRO_ARGS_HPP

#include <nil/marshalling/detail/macro_common.hpp>

//#define MARSHALLING_DO_REVERSE_MACRO_ARGS_0()
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_1(n_) MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_2(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_1(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_3(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_2(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_4(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_3(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_5(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_4(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_6(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_5(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_7(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_6(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_8(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_7(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_9(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_8(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_10(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_9(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_11(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_10(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_12(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_11(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_13(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_12(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_14(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_13(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_15(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_14(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_16(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_15(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_17(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_16(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_18(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_17(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_19(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_18(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_20(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_19(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_21(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_20(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_22(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_21(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_23(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_22(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_24(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_23(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_25(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_24(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_26(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_25(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_27(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_26(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_28(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_27(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_29(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_28(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_30(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_29(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_31(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_30(__VA_ARGS__)), MARSHALLING_EXPAND(n_)
#define MARSHALLING_DO_REVERSE_MACRO_ARGS_32(n_, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_31(__VA_ARGS__)), MARSHALLING_EXPAND(n_)

#define MARSHALLING_REVERSE_MACRO_ARGS_INTERNAL_(N, ...) \
    MARSHALLING_EXPAND(MARSHALLING_DO_REVERSE_MACRO_ARGS_##N(__VA_ARGS__))
#define MARSHALLING_REVERSE_MACRO_ARGS_INTERNAL(N, ...) \
    MARSHALLING_EXPAND(MARSHALLING_REVERSE_MACRO_ARGS_INTERNAL_(N, __VA_ARGS__))
#define MARSHALLING_REVERSE_MACRO_ARGS(...) \
    MARSHALLING_EXPAND(MARSHALLING_REVERSE_MACRO_ARGS_INTERNAL(MARSHALLING_NUM_ARGS(__VA_ARGS__), __VA_ARGS__))
#endif    // MARSHALLING_REVERSE_MACRO_ARGS_HPP
